package cn.fl.customer.service.impl;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.customer.service.ICstCorpTeamResumeService;
import cn.fl.customer.transform.CstCorpTeamResumeVOTransform;
import cn.fl.customer.vo.CstCorpTeamResumeVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.customer.facade.customer.api.ICustomerApiService;
import fl.customer.facade.customer.condition.CstCorpTeamResumeQueryCondition;
import fl.customer.facade.customer.dto.CstCorpTeamResumeDTO;

/**
 * @Description: 法人企业团队成员简历表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class CstCorpTeamResumeServiceImpl implements ICstCorpTeamResumeService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(ICstCorpTeamResumeService.class);
	
	/**
	 * 客户 API 暴露服务
	 */
	@Autowired
	private ICustomerApiService customerApiService;

	@Override
	public CstCorpTeamResumeVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//TODO 业务逻辑
		CstCorpTeamResumeDTO dto = null;//this.自定义ApiService.selectById(id);
		return CstCorpTeamResumeVOTransform.toVO(dto);
	}

	@Override
	public Long add(CstCorpTeamResumeVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//return this.cstCorpTeamResumeApiService.add(CstCorpTeamResumeVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		//return this.cstCorpTeamResumeApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
    		BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(CstCorpTeamResumeVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		//return this.cstCorpTeamResumeApiService.modify(CstCorpTeamResumeVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		page = this.customerApiService.searchCstCorpTeamResumePage(page);
		List<CstCorpTeamResumeDTO> list = (List<CstCorpTeamResumeDTO>) page.getResultList();
		List<CstCorpTeamResumeVO> voList = CstCorpTeamResumeVOTransform.toVOList(list);
		if(CollectionUtils.isNotEmpty(list)){
			for (CstCorpTeamResumeVO cstCorpTeamResumeVO : voList) {
				Date sDt = cstCorpTeamResumeVO.getStartDt();
				if(null != sDt){
					cstCorpTeamResumeVO.setStartDtStr(DateUtils.formatDateToString(sDt, DateUtils.YYYY_MM_DD));
				}else{
					cstCorpTeamResumeVO.setStartDtStr("");
				}
				
				Date eDt = cstCorpTeamResumeVO.getEndDt();
				if(null != eDt){
					cstCorpTeamResumeVO.setEndDtStr(DateUtils.formatDateToString(eDt, DateUtils.YYYY_MM_DD));
				}else{
					cstCorpTeamResumeVO.setEndDtStr("");
				}
			}
		}
		page.setResultList(voList);
		return page;
	}

	@Override
	public List<CstCorpTeamResumeVO> searchList(CstCorpTeamResumeQueryCondition qc) throws BaseException {
		if(null==qc){
			BaseLogUtils.info(logger, "searchList", "cstId对象参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		return CstCorpTeamResumeVOTransform.toVOList(customerApiService.searchCstCorpTeamResumeList(qc));
	}
}
